Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Prisma TypedSQL #377

Open
wants to merge 20 commits into
base: dev
Choose a base branch
from
Open

Added Prisma TypedSQL #377

wants to merge 20 commits into from

Conversation

fomalhautb
Copy link
Contributor

@fomalhautb fomalhautb commented Dec 20, 2024


Important

Introduces Prisma TypedSQL, updates dependencies, and modifies SQL queries to use typed SQL in the backend.

  • Behavior:
    • Updated codegen-prisma:watch script in package.json to use --sql flag.
    • Updated getUsersLastActiveAtMillis in crud.tsx to use prismaClient.$queryRawTyped with getUsersLastActiveAtMillisSql.
  • Dependencies:
    • Updated @prisma/client and prisma to version ^6.1.0 in package.json.
    • Added @electric-sql/pglite, chokidar-cli, and pg-gateway to package.json.
  • Prisma:
    • Added typedSql to previewFeatures in schema.prisma.
  • SQL:
    • Added getUsersLastActiveAtMillis.sql to handle user activity queries.
  • Scripts:
    • Added mock-postgres.mjs to handle database connections using PGlite.
  • Misc:
    • Commented out Sentry initialization in sentry.client.config.ts.

This description was created by Ellipsis for 259a780. It will automatically update as commits are pushed.

Copy link

vercel bot commented Dec 20, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
stack-backend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 24, 2024 7:09pm
stack-dashboard ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 24, 2024 7:09pm
stack-demo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 24, 2024 7:09pm

"codegen-prisma": "pnpm run prisma generate",
"codegen-prisma:watch": "pnpm run prisma generate --watch",
"codegen": "pnpm run with-env bash -c 'if [ \"$STACK_ACCELERATE_ENABLED\" = \"true\" ]; then pnpm run prisma generate --no-engine && pnpm run generate-docs; else pnpm run codegen-prisma && pnpm run generate-docs; fi'",
"codegen-prisma": "concurrently -k -s first \"tsx scripts/mock-postgres.mjs\" \"node -e \\\"setTimeout(() => process.exit(0), 2000)\\\" && cross-env STACK_DATABASE_CONNECTION_STRING=\\\"postgres://postgres@localhost:8118/postgres?pgbouncer=true&connection_limit=1\\\" STACK_DIRECT_DATABASE_CONNECTION_STRING=\\\"postgres://postgres@localhost:8118/postgres?connection_limit=1\\\" STACK_SEED_INTERNAL_PROJECT_PUBLISHABLE_CLIENT_KEY=\\\"test_key\\\" STACK_SEED_INTERNAL_PROJECT_SECRET_SERVER_KEY=\\\"test_secret\\\" STACK_SEED_INTERNAL_PROJECT_SUPER_SECRET_ADMIN_KEY=\\\"test_admin\\\" sh -c \\\"pnpm run prisma migrate reset --force && pnpm run prisma generate --sql\\\"\"",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we put this into a JS file instead (you can merge it with mock-postgres.mjs)

"codegen": "pnpm run with-env bash -c 'if [ \"$STACK_ACCELERATE_ENABLED\" = \"true\" ]; then pnpm run prisma generate --no-engine && pnpm run generate-docs; else pnpm run codegen-prisma && pnpm run generate-docs; fi'",
"codegen-prisma": "concurrently -k -s first \"tsx scripts/mock-postgres.mjs\" \"node -e \\\"setTimeout(() => process.exit(0), 2000)\\\" && cross-env STACK_DATABASE_CONNECTION_STRING=\\\"postgres://postgres@localhost:8118/postgres?pgbouncer=true&connection_limit=1\\\" STACK_DIRECT_DATABASE_CONNECTION_STRING=\\\"postgres://postgres@localhost:8118/postgres?connection_limit=1\\\" STACK_SEED_INTERNAL_PROJECT_PUBLISHABLE_CLIENT_KEY=\\\"test_key\\\" STACK_SEED_INTERNAL_PROJECT_SECRET_SERVER_KEY=\\\"test_secret\\\" STACK_SEED_INTERNAL_PROJECT_SUPER_SECRET_ADMIN_KEY=\\\"test_admin\\\" sh -c \\\"pnpm run prisma migrate reset --force && pnpm run prisma generate --sql\\\"\"",
"codegen-prisma:watch": "pnpm run codegen-prisma && chokidar \"prisma/**/*\" -c \"pnpm run codegen-prisma\"",
"codegen": "pnpm run with-env bash -c 'if [ \"$STACK_ACCELERATE_ENABLED\" = \"true\" ]; then pnpm run prisma generate --sql --no-engine && pnpm run generate-docs; else pnpm run codegen-prisma && pnpm run generate-docs; fi'",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change? Why prisma generate --sql when that environment variable is set, but pnpm run codegen-prisma otherwise?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was testing something, will put it back

})
})

server.listen(8118, () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you document this in the dev launchpad?

.dockerignore Outdated
@@ -57,6 +57,7 @@ packages/adapter-prisma/prisma/migrations
db.sqlite
packages/adapter-supabase/supabase/.branches
packages/adapter-drizzle/.drizzle
pglite-data/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pglite-data/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pglite generates a folder automatically, a lot of files will be committed if we don't ignore it

.gitignore Outdated
@@ -58,6 +58,7 @@ packages/adapter-prisma/prisma/migrations
db.sqlite
packages/adapter-supabase/supabase/.branches
packages/adapter-drizzle/.drizzle
pglite-data/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pglite-data/

.dockerignore Outdated
@@ -136,4 +137,4 @@ node_modules

deploy
!deploy/docker/**/entrypoint.sh
docker-compose.yaml
docker-compose.yaml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
docker-compose.yaml
docker-compose.yaml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants